A static text view allows you to draw non editable text. It is basically a view wrapper for a FW_CTextBoxShape object. You can specify its bounds, text, font and text box options.
When creating one by program you would use one of the 2 class constructors:
FW_CStaticText(Environment* ev,
FW_CSuperView* container,
const FW_CRect& bounds,
const FW_CString& text,
const FW_CFont& font = FW_kNormalFont,
FW_TextBoxOptions options = FW_kTextBoxClipToBox,
const FW_CInk& ink = FW_kNormalTextInk);
FW_CStaticText(Environment* ev,
FW_CSuperView* container,
const FW_CTextBoxShape& textboxshape);
The first one is easier to use with its default values, you can write for example:
In order to change the default ink and text box options you must access the underlying text box shape with GetTextBoxShape and call its methods.
Notes:
• Being views static text objects derive also from FW_MEventHandler, although they are disabled by default. You can re-enable them with Enable() if want them to receive events.
• Another way to draw static text in your frame is to use a background picture as it is done in Form. This is not portable to other platforms but it can be convenient when there is a lot of text.
SetText replace the current string with text. It redraws the view if refresh is true. The text can be displayed on several lines if you created the static text object with the proper text box options, or if the string contains <cr> characters.
GetTextBoxShape returns a pointer to the underlying text box shape. This allows you to modify its attributes. Call staticText->Invalidate(ev) afterward to force a redraw.
Group Box (FW_CGroupBox)
Creation by Program or by Resource
A group box view is a box with a label. FW_CGroupBox derives from FW_CStaticText. The static text is displayed as a label on the top border and the box is drawn using the view bounds rectangle. The label position within the top border depends on the text box options choosen. By default it is placed to the left (FW_kTextBoxJustifyLeft) you can also center it (FW_kTextBoxJustifyHCenter) or place it to the right (FW_kTextBoxJustifyRight).
FW_CGroupBox views are useful to group several other views visually. For instance sets of radio buttons are usually displayed with inside a group box (this is separate from the FW_CRadioCluster object that manages the toggling of radio buttons).
When creating one by program you would use one of the 2 class constructors:
FW_CGroupBox (Environment* ev,
FW_CSuperView* container,
const FW_CRect& bounds,
const FW_CString& text,
const FW_CFont& font = FW_kNormalFont,
FW_TextBoxOptions options = FW_kTextBoxClipToBox,
const FW_CInk& textInk = FW_kNormalTextInk,
const FW_CInk& frameInk = FW_kNormalInk);
FW_CGroupBox (Environment* ev,
FW_CSuperView* container,
const FW_CTextBoxShape& textbox,
const FW_CInk& frameInk = FW_kNormalInk);
The only addition to FW_CStaticText constructors is frameInk, the ink used to draw the box.
The resource type FW_RGroupBox is identical to FW_RStaticText.
API Reference
There is no new API. Use GetText, SetText or GetTextBoxShape to read or modify the text. Use SetSize to change the size of the box.
Grow Box (FW_CGrowBox)
Creation by Program or by Resource
FW_CGrowBox implements the standard Macintosh grow box (doesn't draw anything on other platforms). Create an FW_CGrowBox object in every root frame that can be resized. If your frame is not the root frame, i.e. is embedded somewhere else, it is against HI conventions to leave the grow box.
void MyFrame::CreateSubViews(Environment* ev)
{
...
if (IsRoot(ev))
{
// ----- Create the GrowBox only in root frame
FW_CGrowBox* growBox = new FW_CGrowBox(ev, this, 0, contentRect.BotRight());
}
...
When creating your views by resource you cannot use a runtime test for root frames. The solution is to leave the grow box and add code in PostCreateViewFromStream to remove it afterward for non-root frames.